package org.example.zuoye.api;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.example.zuoye.entity.Result;
import org.example.zuoye.service.ChartsService;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.Map;

/**
 * @Author xinchen
 * @Date: 2024/08/17/ 20:47
 * @Description
 */
@RestController
@RequestMapping("/api/v1/charts")
@RequiredArgsConstructor
@Slf4j
public class ChartsApi {
    private final ChartsService chartsService;


    /**
     * 热门预约医生
     */
    @GetMapping("/hotAppoint")
    public Result hotAppoint(@DateTimeFormat(pattern="yyyy-MM-dd") Date date) {
        return Result.success(chartsService.hotAppoint(new Date()));
    }

    /**
     * 统计患者总数
     */
    @GetMapping("/patientTotal")
    public Result patientTotal() {
        return Result.success(chartsService.getPatientTotal());
    }
    /**
     * 统计医生数量
     */
    @GetMapping("/doctorTotal")
    public Result doctorTotal() {
        return Result.success(chartsService.getDoctorTotal());
    }
    /**
     * 获取放号总数
     */
    @GetMapping("/schedulesTotal")
    public Result scheduleTotal() {
        return Result.success(chartsService.getScheduleTotal());
    }
    /**
     * 获取预约总数
     */
    @GetMapping("/appointTotal")
    public Result appointTotal() {
        return Result.success(chartsService.getAppointTotal());
    }
    /**
     * 本月热门医生放号
     */
    @GetMapping("/hotDoctor")
    public Result hotDoctor(@DateTimeFormat(pattern="yyyy-MM-dd") Date date) {
        log.info("xxxxxxxxxxxxxxxxxxxxxxxx"+String.valueOf(date));
        return Result.success(chartsService.gethotDoctor(date));
    }

    /**
     * 统计每天的预约数量预约趋势
     */
    @GetMapping("/appointCount")
    public Result appointCount(@DateTimeFormat(pattern="yyyy-MM-dd") Date date) {
        return Result.success(chartsService.getAppointCount(date));
    }
    /**
     * 每周每天的放号数量
     */
    @GetMapping("/weekSchedule")
    public Result weekSchedule(@DateTimeFormat(pattern="yyyy-MM-dd") Date date) {
        return Result.success(chartsService.getWeekSchedule(date));
    }

    /**
     * 每周 每天的预约数量
     */
    @GetMapping("/weekAppoint")
    public Result weekAppoint(@DateTimeFormat(pattern="yyyy-MM-dd") Date date) {
        return Result.success(chartsService.getWeekAppoint(date));
    }
}
